package com.example.administrator.android2019.Note;

import android.content.Context;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.example.administrator.android2019.R;

import java.util.ArrayList;

public class NoteAdapter extends BaseAdapter {
    /**
     * 上下文对象，某个Activity
     * */
    private Context context;
    private ArrayList<NoteBean>list;

    public NoteAdapter(Context context, ArrayList<NoteBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {

        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;
        if (convertView==null){
            convertView=View.inflate(context, R.layout.activity_note_list,null);
            viewHolder=new ViewHolder();
            viewHolder.tv_content=convertView.findViewById(R.id.note_item_content);
            viewHolder.tv_time=convertView.findViewById(R.id.note_item_time);
            convertView.setTag(viewHolder);

        }else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        NoteBean noteBean=list.get(position);
        //viewHolder.tv_content.setText()
        return null;
    }
    class ViewHolder{
        TextureView tv_content;
        TextureView tv_time;
    }
}
